﻿/*
 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved.
 */
#include "BurnCtrlFaction.h"
#include "WifiBurnCtrl.h"
#include "BurnCtrl3X.h"
#include "BurnCtrlJLink.h"
#include "BurnCtrlDfu.h"
#include "BurnCtrlMcu.h"
#include "BurnCtrlHsan.h"

BurnCtrlFaction::BurnCtrlFaction()
{
}

BurnCtrlFaction::~BurnCtrlFaction()
{
}

BurnCtrl *BurnCtrlFaction::GetBurnCtrl(ChipType type) const
{
    BurnCtrl *burnCtrler = nullptr;
    if (IsNewWifiBurnCtrl(type)) {
        burnCtrler = new WifiBurnCtrl(type, nullptr);
    } else if (type == ChipType::SPARTA || type == ChipType::MELODY || type == ChipType::COMBS25) {
        burnCtrler = new BurnCtrl3XClass::BurnCtrl3X(type, nullptr);
    } else if (type == ChipType::JLINKBS25 || type == ChipType::JLINKBS2X) {
        burnCtrler = new BurnCtrlJLinkClass::BurnCtrlJLink(type, nullptr);
    } else if (Global::IsUSBType(type)) {
        burnCtrler = new BurnCtrlDfuClass::BurnCtrlDfu(type, nullptr);
    } else if (type == ChipType::DFU) {
        burnCtrler = new BurnCtrlDfuClass::BurnCtrlDfu(type);
    } else if (type == ChipType::MCU) {
        burnCtrler = new BurnToolSpace::BurnCtrlMcu(type, nullptr);
    } else if (Global::IsHsanType(type)) {
        burnCtrler = new BurnToolSpace::BurnCtrlHsan(type);
    } else {
        burnCtrler = new WifiBurnCtrl(type, nullptr);
    }
    return burnCtrler;
}

bool BurnCtrlFaction::IsNewWifiBurnCtrl(ChipType type) const
{
    return type == ChipType::WIFI5GNB || type == ChipType::WIFIURANUS ||
        type == ChipType::SWAN || type == ChipType::WIFIDW31 ||
        type == ChipType::BS2X || Global::IsWs63(type) || type == ChipType::WS53 ||
        type == ChipType::WIFI4GCAT1 || type == ChipType::SW39 || type == ChipType::SW21 ||
        type == ChipType::HI3372 || type == ChipType::HI3322 || type == ChipType::COM2982;
}
